# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.
import traceback, re
from datetime import datetime
import os
import shutil
import time
from pypdf import PdfMerger
from form import Form
from expert import Expert
from save_file import SaveFileForm
from progress import ProgressBar
from success import Success
from error import Error
from exit import ErrorWindow
from temp import Excel, ReadExcel
from backend import full_l3, full_l4, full_l6, full_v12, full_v6, full_v8
from ui_py.main_ui import Ui_MainWindow
from classes.engine import Engine
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QButtonGroup, QApplication, QMessageBox
from PyQt5.QtCore import QTranslator
from output_data import MainWindow
from temp import Graphics, MainWidget, BigMainWidget
from dataExpert import Data
import json
from page1 import Page1
from page2 import Page2
from page3 import Page3
from page4 import Page4
from page5 import Page5
from page6 import Page6
from page7 import Page7
import glob
import logging
dict_engine = {
    1: "L4",
    2: "L6",
    3: "V8",
    4: "L3",
    5: "V6",
    6: "V12"
}
class Manager():
    count = 1
    def __init__(self):
        self.arr = []
    def mainW(self):
        window = self.new_window()
        window.setMinimumHeight(900)
        window.setMinimumWidth(1380)
        self.add_window(window)
        self.exec_window()
    def add_window(self, w):
        self.arr.append(w)
    def exec_window(self):
        for i in self.arr:
            i.show()
    def new_window(self):
        window = mainClass(self.count)
        self.count += 1
        return window

class mainClass(QtWidgets.QMainWindow, Ui_MainWindow):
    engine = Engine()
    try:
        logging.basicConfig(level=logging.INFO, filename="py.log",filemode="a", format="%(asctime)s\n%(message)s\n")
    except:
        pass
    def __init__(self):
        super().__init__()
        with open("lang.json", encoding='utf-8') as file:
            data = json.load(file)
        if data['lang'] != '':
            self.trans = QTranslator(self)
            self.trans.load('translate/' + data['lang'])
            _app = QApplication.instance() # получить экземпляр приложения
            _app.installTranslator(self.trans)
        self.setupUi(self)
        self.dict_from_excel = {}
        self.radio = 0
        self.path_to_folder = "data"
        self.path_to_file = ""
        self.path_to_res = ""
        self.from_file = 0
        self.path_from_file = ""
        self.count_was = False
        self.data = Data()
        self.ex = ErrorWindow()
        self.success = Success()
        self.progressBar = ProgressBar()
        self.expert = Expert()
        self.countPage = MainWindow()
        self.saveFileForm = SaveFileForm()
        self.err = Error()
        # self.first_mode_countPage = MainWindow('Первый режим нагружения')
        # self.second_mode_countPage = MainWindow('Второй режим нагружения')
        # self.third_mode_countPage = MainWindow('Третий режим нагружения')
        self.first = BigMainWidget(False, 'main')
        self.second = BigMainWidget(True, 'main')
        self.third = BigMainWidget(True, 'main')
        self.forth = BigMainWidget(True, 'main')
        self.fifth = BigMainWidget(True, 'main')
        self.AreTabsHere = False

        self.manager = Manager()
        # self.grapAndTable = MainWindow()
        self.action_.triggered.connect(self.action_1)
        self.action_2.triggered.connect(self.action2_)
        self.action_3.triggered.connect(self.action3_)
        self.action_4.triggered.connect(self.action4_)
        self.action_5.triggered.connect(self.action5_)
        self.action_2.setEnabled(False)
        self.action_3.setEnabled(False)
        self.pushButton_24.setEnabled(False)
        self.pushButton_23.setEnabled(False)
        self.pushButton.clicked.connect(self.show_page1)
        self.pushButton_2.clicked.connect(self.show_page2)
        self.pushButton_3.clicked.connect(self.show_page3)
        self.pushButton_7.clicked.connect(self.show_page4)
        self.pushButton_4.clicked.connect(self.show_page5)
        self.pushButton_5.clicked.connect(self.show_page6)
        self.pushButton_24.clicked.connect(self.save)
        self.pushButton_23.clicked.connect(self.save_as)
        self.pushButton_6.clicked.connect(self.show_page7)
        if data['lang'] != '':
            page = data['en']['main']
            self.comboBox.addItem(page['engine'])
            self.comboBox.setCurrentText(page['engine'])
        else:
            self.comboBox.addItem("Выберите двигатель")
            self.comboBox.setCurrentText("Выберите двигатель")
        # self.group = QButtonGroup()
        # self.group.setExclusive(False)
        # self.group.addButton(self.radioButton_2)
        # self.group.addButton(self.radioButton_3)
        # self.group.addButton(self.radioButton_4)
        # self.group.buttonClicked.connect(self.radio_buttons)
        # self.comboBox_2.currentIndexChanged.connect(self.tact_engine)
        # self.comboBox_2.addItem("4-тактный", 1)
        # self.comboBox_2.addItem("2-тактный", 2)
        # self.comboBox_2.setPlaceholderText("Выберите")
        self.pushButton_21.clicked.connect(self.outputGraphicsAndValues)
        self.pushButton_21.setEnabled(True)
        if self.engine.cil == "":
            self.toolBox.setEnabled(False)
            self.pushButton_4.setEnabled(False)
            self.pushButton_5.setEnabled(False)
            self.pushButton_6.setEnabled(False)
            self.pushButton_7.setEnabled(False)
            self.pushButton_21.setEnabled(False)
        self.page1 = Page1()
        self.page2 = Page2()
        self.page3 = Page3()
        self.page4 = Page4()
        self.page5 = Page5()
        self.page6 = Page6()
        self.page7 = Page7(self.path_to_file)
        self.comboBox.currentIndexChanged.connect(self.handleActivated)
    def restart(self):
        with open('lang.json', encoding='utf-8') as file:
            data = json.load(file)
        if data['lang'] == "":
            data['lang'] = "eng-rus"
        else:
            data['lang'] = ""
        with open('lang.json', 'w', encoding='utf-8') as file:
            json.dump(data, file)
        QtCore.QCoreApplication.quit()
        status = QtCore.QProcess.startDetached(sys.executable, sys.argv)

    def action4_(self):
        with open('lang.json', encoding='utf-8') as file:
            data = json.load(file)
        if data['lang'] != '':
            file = QFileDialog.getExistingDirectory(self, "Open project")
        else:
            file = QFileDialog.getExistingDirectory(self, "Открыть проект")
        if file:
            self.from_file = 1
            self.expert.from_file = 1
            self.path_from_file = file
            self.data.extern_file = file
            self.pushButton_24.setEnabled(True)
            self.pushButton_23.setEnabled(True)
            if os.path.isdir('data'):
                shutil.rmtree('data')
            os.mkdir('data')
            self.path_to_folder = "data"
            if os.path.isdir('mode1'):
                shutil.rmtree('mode1')
            if os.path.isdir('mode2'):
                shutil.rmtree('mode2')
            if os.path.isdir('mode3'):
                shutil.rmtree('mode3')
            shutil.copytree(file, self.path_to_folder, dirs_exist_ok=True)
            try:
                self.data.excel = ReadExcel(glob.glob(self.path_to_folder + '/*.xlsx')[0]).getAllLists()
                self.dict_from_excel = ReadExcel(glob.glob(self.path_to_folder + '/' + '*.xlsx')[0]).getAllLists()
                self.path_to_file = glob.glob(self.path_to_folder + '/' + '*.xlsx')[0]
                self.engine.cil = dict_engine[ReadExcel(glob.glob(self.path_to_folder + '/' + '*.xlsx')[0]).getEngine()]
                self.expert.engine_type = self.engine.cil
                with open('data/app.json') as file:
                    data = json.load(file)
                try:
                    if data['input_mode1']:
                        self.expert.input_mode1 = data['input_mode1']
                        try:
                            excel = ReadExcel(glob.glob("data/mode1/*.xlsx")[0])
                            self.expert.dict_mode1 = excel.getModeParam()
                        except:pass
                        self.expert.paths_to_folders.append('data/mode1')
                        self.expert.paths_to_res.append(glob.glob('data/mode1/*.xlsx')[0])
                        self.expert.modes.append(2)
                    if data['input_mode2']:
                        self.expert.input_mode2 = data['input_mode2']
                        try:
                            excel = ReadExcel(glob.glob("data/mode2/*.xlsx")[0])
                            self.expert.dict_mode2 = excel.getModeParam()
                        except:pass
                        self.expert.paths_to_folders.append('data/mode2')
                        self.expert.paths_to_res.append(glob.glob('data/mode2/*.xlsx')[0])
                        self.expert.modes.append(3)
                    if data['input_mode3']:
                        self.expert.input_mode3 = data['input_mode3']
                        try:
                            excel = ReadExcel(glob.glob("data/mode3/*.xlsx")[0])
                            self.expert.dict_mode3 = excel.getModeParam()
                        except:pass
                        self.expert.paths_to_folders.append('data/mode3')
                        self.expert.paths_to_res.append(glob.glob('data/mode3/*.xlsx')[0])
                        self.expert.modes.append(4)
                except:
                    pass
                match self.engine.cil:
                    case "L3":
                        self.expert.cylinder = 3
                        self.expert.root_bearing = 4
                    case "L4":
                        self.expert.cylinder = 4
                        self.expert.root_bearing = 5
                    case "L6":
                        self.expert.cylinder = 6
                        self.expert.root_bearing = 7
                    case "V6":
                        self.expert.cylinder = 6
                        self.expert.root_bearing = 4
                    case "V8":
                        self.expert.cylinder = 8
                        self.expert.root_bearing = 5
                    case "V12":
                        self.expert.cylinder = 12
                        self.expert.root_bearing = 7
                self.comboBox.blockSignals(True)
                self.comboBox.setCurrentText(self.engine.cil)
                self.comboBox.blockSignals(False)
                if self.stackedWidget.currentWidget() == self.page1:
                    self.stackedWidget.removeWidget(self.page1)
                    self.page1 = Page1()
                    self.stackedWidget.addWidget(self.page1)
                    self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
                elif self.stackedWidget.currentWidget() == self.page2:
                    self.stackedWidget.removeWidget(self.page2)
                    self.page2 = Page2()
                    self.stackedWidget.addWidget(self.page2)
                    self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
                elif self.stackedWidget.currentWidget() == self.page3:
                    self.stackedWidget.removeWidget(self.page3)
                    self.page3 = Page3()
                    self.stackedWidget.addWidget(self.page3)
                    self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
                elif self.stackedWidget.currentWidget() == self.page4:
                    self.stackedWidget.removeWidget(self.page4)
                    self.page4 = Page4()
                    self.stackedWidget.addWidget(self.page4)
                    self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
                elif self.stackedWidget.currentWidget() == self.page5:
                    self.stackedWidget.removeWidget(self.page5)
                    self.page5 = Page5()
                    self.stackedWidget.addWidget(self.page5)
                    self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
                elif self.stackedWidget.currentWidget() == self.page6:
                    self.stackedWidget.removeWidget(self.page6)
                    self.page6 = Page6()
                    self.stackedWidget.addWidget(self.page6)
                    self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
                elif self.stackedWidget.currentWidget() == self.page7:
                    self.stackedWidget.removeWidget(self.page7)
                    self.page7 = Page7(self.path_to_file)
                    self.stackedWidget.addWidget(self.page7)
                    self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
                self.comboBox.setEnabled(False)
                self.toolBox.setEnabled(True)
                self.pushButton_4.setEnabled(True)
                self.pushButton_5.setEnabled(True)
                self.pushButton_6.setEnabled(True)
                self.pushButton_7.setEnabled(True)
                self.pushButton.setEnabled(True)
                self.pushButton_2.setEnabled(True)
                self.pushButton_3.setEnabled(True)
                self.pushButton_21.setEnabled(True)
            except:
                msg = QMessageBox()
                if data['lang'] != '':
                    msg.critical(None, "Error", "The wrong folder was selected")
                else:
                    msg.critical(None, "Ошибка", "Выбрана неверная папка")
        

    def save(self):
        self.progressBar.clear()
        if len(self.expert.paths_to_folders_without_count):

            self.progressBar.show()
            QApplication.processEvents()

            print(f"self.expert.paths_to_folders_without_count {self.expert.paths_to_folders_without_count}")

            for i in range(len(self.expert.paths_to_folders_without_count)):
                fl = 0
                if re.search(f"mode1", self.expert.paths_to_folders_without_count[i]):
                    fl = 1
                elif re.search(f"mode2", self.expert.paths_to_folders_without_count[i]):
                    fl = 2
                elif re.search(f"mode3", self.expert.paths_to_folders_without_count[i]):
                    fl = 3
                self.progressBar.setValue(0, 8)
                QApplication.processEvents()
                if self.expert.engine_type == 'L3':                
                    full_l3.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_l3.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_l3.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_l3.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'L4':
                    full_l4.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_l4.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_l4.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_l4.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'L6':
                    full_l6.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_l6.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_l6.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_l6.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'V6':
                    full_v6.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_v6.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_v6.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_v6.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'V8':
                    full_v8.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_v8.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_v8.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_v8.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'V12':
                    full_v12.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_v12.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_v12.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_v12.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

            self.progressBar.setValue2(75, 85)
            QApplication.processEvents()
            self.progressBar.close()
            self.expert.paths_to_folders_without_count = []
        self.progressBar.show()
        self.progressBar.label.setText("Обновление данных")
        QApplication.processEvents()
        file = glob.glob('data/*.xlsx')[0]
        exc = ReadExcel(file)
        for i in self.expert.excel.keys():
            exc.updateCell(i, self.expert.excel[i], file)
        self.progressBar.setValue2(0, 18)
        QApplication.processEvents()
        try:
            file = glob.glob('data/mode1/*.xlsx')[0]
            exc = ReadExcel(file)
            for i in self.expert.excel.keys():
                exc.updateCell(i, self.expert.excel[i], file)
            # file = glob.glob('data/mode1/*.xlsx')[0]
            # exc = ReadExcel(file)
            for i in self.expert.dict_mode1.keys():
                exc.updateCell(i, self.expert.dict_mode1[i], file)
        except:
            pass
        self.progressBar.setValue2(18, 43)
        QApplication.processEvents()
        try:
            file = glob.glob('data/mode2/*.xlsx')[0]
            exc = ReadExcel(file)
            for i in self.expert.excel.keys():
                exc.updateCell(i, self.expert.excel[i], file)
            # file = glob.glob('data/mode2/*.xlsx')[0]
            # exc = ReadExcel(file)
            for i in self.expert.dict_mode2.keys():
                exc.updateCell(i, self.expert.dict_mode2[i], file)
        except:
            pass
        self.progressBar.setValue2(43, 85)
        QApplication.processEvents()
        try:
            file = glob.glob('data/mode3/*.xlsx')[0]
            exc = ReadExcel(file)
            for i in self.expert.excel.keys():
                exc.updateCell(i, self.expert.excel[i], file)
            # file = glob.glob('data/mode3/*.xlsx')[0]
            # exc = ReadExcel(file)
            for i in self.expert.dict_mode3.keys():
                exc.updateCell(i, self.expert.dict_mode3[i], file)
        except:
            pass
        # try:
        #     set_with_count = set(self.expert.paths_to_res_with_count)
        #     set_all_modes = set(self.expert.paths_to_res)

        #     set_without_count = set_all_modes.symmetric_difference(set_with_count)

        #     for i in range(len(set_without_count)):
        #         grap = Graphics(set_without_count[i], 1)
        # except:
        #     pass
        self.progressBar.setValue2(85, 95)
        QApplication.processEvents()
        # try:
        #     pdfs = ['data/test.pdf', 'data/mode1.pdf', 'data/mode2.pdf', 'data/mode3.pdf']
        #     merger = PdfMerger()
        #     for pdf in pdfs:
        #         try:
        #             merger.append(pdf)
        #         except:
        #             pass
        #     if len(merger.pages):
        #         merger.write('data/report.pdf')
        #     merger.close()
        # except:
        #     pass
        # try:
        #     if self.path_to_res != "":
        #         grap = Graphics(self.path_to_res, 1)
        #         match dict_engine[self.dict_from_excel['cil']]:
        #             case "L3":
        #                 grap.save_l3_v6_graphics(self.path_to_folder)
        #             case "L4":
        #                 grap.save_l4_v8_graphics(self.path_to_folder)
        #             case "L6":
        #                 grap.save_l6_v12_graphics(self.path_to_folder)
        #             case "V6":
        #                 grap.save_l3_v6_graphics(self.path_to_folder)
        #             case "V8":
        #                 grap.save_l4_v8_graphics(self.path_to_folder)
        #             case "V12":
        #                 grap.save_l6_v12_graphics(self.path_to_folder)
        # except:
        #     pass
        if self.from_file == 1:
            word = '_res.xlsx'
            pattern = f"{self.path_to_folder}/*{word}*"
            print(self.path_to_folder, self.path_from_file)
            shutil.copytree(self.path_to_folder, self.path_from_file, dirs_exist_ok=True)
            self.data.saveIs = True
        else:
            with open('lang.json', encoding='utf-8') as file:
                data = json.load(file)
            if data['lang'] != '':
                filename = QFileDialog.getExistingDirectory(self, "Save project")
            else:
                filename = QFileDialog.getExistingDirectory(self, "Сохранить проект")
            if filename:
                while True:
                    self.saveFileForm.exec()
                    if self.saveFileForm.label2 == "":
                        break
                    try:
                        os.mkdir(filename + '/' + str(self.saveFileForm.label2))
                        shutil.copytree(self.path_to_folder, filename + '/' + str(self.saveFileForm.label2), dirs_exist_ok=True)
                        break
                    except FileExistsError:
                        msg = QMessageBox()
                        if data['lang'] != '':
                            msg.critical(None, "Error", "Folder already exists")
                        else:
                            msg.critical(None, "Ошибка", "Папка с таким именем уже существует")
                self.from_file = 1
                self.expert.from_file = 1
                self.path_from_file = filename + '/' + str(self.saveFileForm.label2)
                self.success.show()
                self.data.saveIs = True

        self.progressBar.setValue2(95, 100)
        QApplication.processEvents()
        self.progressBar.close()

    def save_as(self):
        self.progressBar.clear()
        if len(self.expert.paths_to_folders_without_count):

            self.progressBar.show()
            QApplication.processEvents()

            print(f"self.expert.paths_to_folders_without_count {self.expert.paths_to_folders_without_count}")

            for i in range(len(self.expert.paths_to_folders_without_count)):
                fl = 0
                if re.search(f"mode1", self.expert.paths_to_folders_without_count[i]):
                    fl = 1
                elif re.search(f"mode2", self.expert.paths_to_folders_without_count[i]):
                    fl = 2
                elif re.search(f"mode3", self.expert.paths_to_folders_without_count[i]):
                    fl = 3
                self.progressBar.setValue2(0, 8)
                QApplication.processEvents()
                if self.expert.engine_type == 'L3':
                    full_l3.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_l3.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_l3.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_l3.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'L4':
                    full_l4.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_l4.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_l4.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_l4.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'L6':
                    full_l6.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_l6.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_l6.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_l6.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'V6':
                    full_v6.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_v6.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_v6.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_v6.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'V8':
                    full_v8.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_v8.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_v8.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_v8.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()

                if self.expert.engine_type == 'V12':
                    full_v12.code_2(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(8, 35)
                    QApplication.processEvents()
                    full_v12.code_3(self.expert.paths_to_folders_without_count[i])
                    self.progressBar.setValue2(35, 65)
                    QApplication.processEvents()
                    full_v12.code_4(self.expert.paths_to_folders_without_count[i], fl)
                    full_v12.code_5(self.expert.paths_to_folders_without_count[i], self.expert)
                    self.progressBar.setValue2(65, 75)
                    QApplication.processEvents()
            
            self.progressBar.setValue2(75, 85)
            QApplication.processEvents()
            self.progressBar.close()
            self.expert.paths_to_folders_without_count = []
        for i in self.expert.excel.keys():
            if i == 'nw' or i == 'Conmass':
                continue
            file = glob.glob('data/*.xlsx')[0]
            exc = ReadExcel(file)
            exc.updateCell(i, self.expert.excel[i], file)
        try:
            for i in self.expert.excel.keys():
                if i == 'nw' or i == 'Conmass':
                    continue
                file = glob.glob('data/mode1/*.xlsx')[0]
                exc = ReadExcel(file)
                exc.updateCell(i, self.expert.excel[i], file)
            for i in self.expert.dict_mode1.keys():
                file = glob.glob('data/mode1/*.xlsx')[0]
                exc = ReadExcel(file)
                exc.updateCell(i, self.expert.dict_mode1[i], file)
        except:
            pass

        try:
            for i in self.expert.excel.keys():
                if i == 'nw' or i == 'Conmass':
                    continue
                file = glob.glob('data/mode2/*.xlsx')[0]
                exc = ReadExcel(file)
                exc.updateCell(i, self.expert.excel[i], file)
            for i in self.expert.dict_mode2.keys():
                file = glob.glob('data/mode2/*.xlsx')[0]
                exc = ReadExcel(file)
                exc.updateCell(i, self.expert.dict_mode2[i], file)
        except:
            pass
        try:
            for i in self.expert.excel.keys():
                if i == 'nw' or i == 'Conmass':
                    continue
                file = glob.glob('data/mode3/*.xlsx')[0]
                exc = ReadExcel(file)
                exc.updateCell(i, self.expert.excel[i], file)
            for i in self.expert.dict_mode3.keys():
                file = glob.glob('data/mode3/*.xlsx')[0]
                exc = ReadExcel(file)
                exc.updateCell(i, self.expert.dict_mode3[i], file)
        except:
            pass
        # try:
        #     set_with_count = set(self.expert.paths_to_res_with_count)
        #     set_all_modes = set(self.expert.paths_to_res)

        #     set_without_count = set_all_modes.symmetric_difference(set_with_count)

        #     for i in range(len(set_without_count)):
        #         grap = Graphics(set_without_count[i], 1)
        # except:
        #     pass

        # try:
        #     pdfs = ['data/test.pdf', 'data/mode1.pdf', 'data/mode2.pdf', 'data/mode3.pdf']
        #     merger = PdfMerger()
        #     for pdf in pdfs:
        #         try:
        #             merger.append(pdf)
        #         except:
        #             pass
        #     if len(merger.pages):
        #         merger.write('data/report.pdf')
        #     merger.close()
        # except:
        #     pass
        # try:
        #     if self.path_to_res != "":
        #         grap = Graphics(self.path_to_res)
        #         match dict_engine[self.dict_from_excel['cil']]:
        #             case "L3":
        #                 grap.save_l3_v6_graphics(self.path_to_folder)
        #             case "L4":
        #                 grap.save_l4_v8_graphics(self.path_to_folder)
        #             case "L6":
        #                 grap.save_l6_v12_graphics(self.path_to_folder)
        #             case "V6":
        #                 grap.save_l3_v6_graphics(self.path_to_folder)
        #             case "V8":
        #                 grap.save_l4_v8_graphics(self.path_to_folder)
        #             case "V12":
        #                 grap.save_l6_v12_graphics(self.path_to_folder)
        # except:
        #     pass
        with open('lang.json', encoding='utf-8') as file:
            data = json.load(file)
        if data['lang'] != '':
            filename = QFileDialog.getExistingDirectory(self, "Save File")
        else:
            filename = QFileDialog.getExistingDirectory(self, "Сохранить проект")
        if filename:
            while True:
                self.saveFileForm.exec()
                if self.saveFileForm.label2 == "":
                    break
                try:
                    os.mkdir(filename + '/' + str(self.saveFileForm.label2))
                    shutil.copytree(self.path_to_folder, filename + '/' + str(self.saveFileForm.label2), dirs_exist_ok=True)
                    break
                except FileExistsError:
                    msg = QMessageBox()
                    if data['lang'] != '':
                        msg.critical(None, "Error", "Folder already exists")
                    else:
                        msg.critical(None, "Ошибка", "Файл с таким именем уже существует")
            self.from_file = 1
            self.expert.from_file = 1
            self.path_from_file = filename + '/' + str(self.saveFileForm.label2)
            self.success.show()
            self.data.saveIs = True
    def close_ev(self):
        self.close()
    def closeEvent(self, event):
        if not self.data.saveIs:
            try:
                with open("data/app.json") as file:
                    data = json.load(file)
                if len(data.keys()):
                    reply = QMessageBox.question(
                    self, "Сохранение",
                    "Вы уверены, что хотите выйти?",
                    QMessageBox.Save | QMessageBox.Close,
                    QMessageBox.Save)

                    if reply == QMessageBox.Close:
                        event.accept()
                    else:
                        event.ignore()
                        self.save()
                elif self.expert.from_file and (len(self.expert.excel.keys()) or len(self.expert.dict_mode1.keys()) or len(self.expert.dict_mode2.keys()) or len(self.expert.dict_mode3.keys())):
                    reply = QMessageBox.question(
                        self, "Сохранение",
                        "Вы уверены, что хотите выйти?",
                        QMessageBox.Save | QMessageBox.Close,
                        QMessageBox.Save)

                    if reply == QMessageBox.Close:
                        event.accept()
                    else:
                        event.ignore()
                        self.save()
                elif not self.expert.from_file and os.path.isdir('data'):
                    reply = QMessageBox.question(
                        self, "Сохранение",
                        "Вы уверены, что хотите выйти?",
                        QMessageBox.Save | QMessageBox.Close,
                        QMessageBox.Save)

                    if reply == QMessageBox.Close:
                        event.accept()
                    else:
                        event.ignore()
                        self.save()
            except:pass
        if os.path.isdir("data"):
            shutil.rmtree("data")
        with open('lang.json', 'r') as file:
            data = json.load(file)
        data['lang'] = ""
        with open('lang.json', 'w') as file:
            json.dump(data, file)
        self.countPage.close()
    def action_1(self):
        self.manager.mainW()
    def action3_(self):
        self.save_as()
    def action2_(self):
        self.save()
    def action5_(self):
        self.restart()
        # with open('lang.json', encoding='utf-8') as file:
        #     data = json.load(file)

    # def on_threadSignal(self, value):
    #     self.progressBar.show()
    def outputGraphicsAndValues(self):
        self.progressBar.clear()
        self.data.current_mode = sorted(self.expert.modes)[0]

        self.data.ugwt_mode1 = []
        self.data.ugwt1_mode1 = []
        self.data.ugwt2_mode1 = []
        self.data.ugwt3_mode1 = []
        self.data.ugwt4_mode1 = []
        self.data.ugwt5_mode1 = []
        self.data.ugwt6_mode1 = []
        self.data.ugwt7_mode1 = []

        self.data.ugwt_mode2 = []
        self.data.ugwt1_mode2 = []
        self.data.ugwt2_mode2 = []
        self.data.ugwt3_mode2 = []
        self.data.ugwt4_mode2 = []
        self.data.ugwt5_mode2 = []
        self.data.ugwt6_mode2 = []
        self.data.ugwt7_mode2 = []

        self.data.ugwt_mode3 = []
        self.data.ugwt1_mode3 = []
        self.data.ugwt2_mode3 = []
        self.data.ugwt3_mode3 = []
        self.data.ugwt4_mode3 = []
        self.data.ugwt5_mode3 = []
        self.data.ugwt6_mode3 = []
        self.data.ugwt7_mode3 = []

        self.countPage.close()
        print(self.expert.change_phase)
        print(self.expert.paths_to_res, self.expert.paths_to_folders)
        print(datetime.now().time())
        with open('lang.json', encoding='utf-8') as file:
            dataf = json.load(file)
        print(datetime.now().time())
        self.progressBar.progressBar.setProperty("value", 0)
        self.progressBar.label.setText("Обновление данных")
        self.progressBar.show()
        QApplication.processEvents()
        print(datetime.now().time())
        if self.data.excel['Conrod'] == None:
            msg = QMessageBox()
            if dataf['lang'] != '':
                msg.critical(None, "Error", "The method of calculating the inertia of the conrod is not selected")
            else:
                msg.critical(None, "Ошибка", "Не выбран способ расчета\nинерции шатуна")
            self.progressBar.close()
            return 3
        print(datetime.now().time())
        if self.data.excel['Conmass'] == None:
            msg = QMessageBox()
            if dataf['lang'] != '':
                msg.critical(None, "Error", "The method of introducing unbalanced crankshaft forces is not selected")
            else:
                msg.critical(None, "Ошибка", "Не выбран cпособ ввода неуравновешенных сил КВ")
            self.progressBar.close()
            return 3
        print(datetime.now().time())
        if self.data.excel['nw'] == None:
            msg = QMessageBox()
            if dataf['lang'] != '':
                msg.critical(None, "Error", "The liner design option is not selected")
            else:
                msg.critical(None, "Ошибка", "Не выбран вариант конструкции вкладышей")
            self.progressBar.close()
            return 3
        print(datetime.now().time())
        if self.data.excel['ms'] == None:
            msg = QMessageBox()
            if dataf['lang'] != '':
                msg.critical(None, "Error", "The type of oil used is not selected")
            else:
                msg.critical(None, "Ошибка", "Не выбран тип применяемого масла")
            self.progressBar.close()
            return 3
        print(datetime.now().time())
        if self.data.excel['iwar'] == None:
            msg = QMessageBox()
            if dataf['lang'] != '':
                msg.critical(None, "Error", "The order of operation of the cylinders is not selected")
            else:
                msg.critical(None, "Ошибка", "Не выбран порядок работы цилиндров")
            self.progressBar.close()
            return 3
        print(datetime.now().time())
        if len(self.err.error_dict.keys()) > 0:
            msg = QMessageBox()
            if dataf['lang'] != '':
                msg.critical(None, "Error", "The data has not been validated")
            else:
                msg.critical(None, "Ошибка", "Данные не прошли валидацию")
            self.progressBar.close()
            return 3
        print(datetime.now().time())
        self.expert.paths_to_res_with_count = []
        # self.progressBar.label.setText("1 расчет")
        file = glob.glob('data/*.xlsx')[0]
        exc = ReadExcel(file)
        for i in self.expert.excel.keys():
            if i == 'nw' or i == 'Conmass':
                continue
            exc.updateCell(i, self.expert.excel[i], file)
        if 2 in self.expert.modes:
            print(datetime.now().time(), "start")
            file = glob.glob('data/mode1/*.xlsx')[0]
            exc = ReadExcel(file)
            for i in self.expert.excel.keys():
                if i == 'nw' or i == 'Conmass':
                    continue
                exc.updateCell(i, self.expert.excel[i], file)
            # file = glob.glob('data/mode1/*.xlsx')[0]
            # exc = ReadExcel(file)
            print(datetime.now().time(), "excel fin")
            for i in self.expert.dict_mode1.keys():
                exc.updateCell(i, self.expert.dict_mode1[i], file)
            print(datetime.now().time(), "dict_mode1 fin")
        if 3 in self.expert.modes:
            file = glob.glob('data/mode2/*.xlsx')[0]
            exc = ReadExcel(file)
            for i in self.expert.dict_mode2.keys():
                exc.updateCell(i, self.expert.dict_mode2[i], file)

            # file = glob.glob('data/mode2/*.xlsx')[0]
            # exc = ReadExcel(file)
            for i in self.expert.excel.keys():
                if i == 'nw' or i == 'Conmass':
                    continue
                exc.updateCell(i, self.expert.excel[i], file)
        print(datetime.now().time())
        if 4 in self.expert.modes:
            file = glob.glob('data/mode3/*.xlsx')[0]
            exc = ReadExcel(file)
            for i in self.expert.dict_mode3.keys():
                exc.updateCell(i, self.expert.dict_mode3[i], file)

            # file = glob.glob('data/mode3/*.xlsx')[0]
            # exc = ReadExcel(file)
            for i in self.expert.excel.keys():
                if i == 'nw' or i == 'Conmass':
                    continue
                exc.updateCell(i, self.expert.excel[i], file)
        self.progressBar.setValue(0, 8)
        with open('data/app.json') as file:
            datafile = json.load(file)
        if 'input_mode1' in datafile:
            if datafile['input_mode1'] == 1:
                print(self.expert.dict_mode1)
                if len(self.expert.dict_mode1) < 4:
                    msg = QMessageBox()
                    if dataf['lang'] != '':
                        msg.critical(None, "Error", "Not all data has been entered")
                    else:
                        msg.critical(None, "Ошибка", "Введены не все данные")
                    self.progressBar.close()
                    return 3
            elif datafile['input_mode1'] == 2:
                if len(self.expert.dict_mode1) < 2:
                    msg = QMessageBox()
                    if dataf['lang'] != '':
                        msg.critical(None, "Error", "Not all data has been entered")
                    else:
                        msg.critical(None, "Ошибка", "Введены не все данные")
                    self.progressBar.close()
                    return 3
        if 'input_mode2' in datafile:
            if datafile['input_mode2'] == 1:
                if len(self.expert.dict_mode2) < 4:
                    msg = QMessageBox()
                    if dataf['lang'] != '':
                        msg.critical(None, "Error", "Not all data has been entered")
                    else:
                        msg.critical(None, "Ошибка", "Введены не все данные")
                    self.progressBar.close()
                    return 3
            elif datafile['input_mode2'] == 2:
                if len(self.expert.dict_mode2) < 2:
                    msg = QMessageBox()
                    if dataf['lang'] != '':
                        msg.critical(None, "Error", "Not all data has been entered")
                    else:
                        msg.critical(None, "Ошибка", "Введены не все данные")
                    self.progressBar.close()
                    return 3
        if 'input_mode3' in datafile:
            if datafile['input_mode3'] == 1:
                if len(self.expert.dict_mode3) < 4:
                    msg = QMessageBox()
                    if dataf['lang'] != '':
                        msg.critical(None, "Error", "Not all data has been entered")
                    else:
                        msg.critical(None, "Ошибка", "Введены не все данные")
                    self.progressBar.close()
                    return 3
            elif datafile['input_mode3'] == 2:
                if len(self.expert.dict_mode3) < 2:
                    msg = QMessageBox()
                    if dataf['lang'] != '':
                        msg.critical(None, "Error", "Not all data has been entered")
                    else:
                        msg.critical(None, "Ошибка", "Введены не все данные")
                    self.progressBar.close()
                    return 3
        if len(self.expert.modes) == 0:
            if len(self.expert.dict_mode3) == 0:
                msg = QMessageBox()
                if dataf['lang'] != '':
                    msg.critical(None, "Error", "Not all data has been entered")
                else:
                    msg.critical(None, "Ошибка", "Введены не все данные")
                self.progressBar.close()
                return 3
            
        elif self.expert.modes[0] == 2:
            if len(self.expert.dict_mode1) == 0:
                msg = QMessageBox()
                if dataf['lang'] != '':
                    msg.critical(None, "Error", "Not all data has been entered")
                else:
                    msg.critical(None, "Ошибка", "Введены не все данные")
                self.progressBar.close()
                return 3
        elif self.expert.modes[0] == 3:
            if len(self.expert.dict_mode2) == 0:
                msg = QMessageBox()
                if dataf['lang'] != '':
                    msg.critical(None, "Error", "Not all data has been entered")
                else:
                    msg.critical(None, "Ошибка", "Введены не все данные")
                self.progressBar.close()
                return 3
        elif self.expert.modes[0] == 4:
            if len(self.expert.dict_mode3) == 0:
                msg = QMessageBox()
                if dataf['lang'] != '':
                    msg.critical(None, "Error", "Not all data has been entered")
                else:
                    msg.critical(None, "Ошибка", "Введены не все данные")
                self.progressBar.close()
                return 3
        if self.engine.cil == "L4" or self.engine.cil == "V8":
            if self.data.excel['MN101'] == '-' or self.data.excel['MN102'] == '-' or self.data.excel['MN201'] == '-' or self.data.excel['MN202'] == '-' or self.data.excel['MN301'] == '-'\
            or self.data.excel['MN302'] == '-' or self.data.excel['MN401'] == '-' or self.data.excel['MN402'] == '-' or self.data.excel['MN501'] == '-' or self.data.excel['MN502'] == '-':
                msg = QMessageBox()
                if dataf['lang'] != '':
                    msg.critical(None, "Error", "No oil grooves have been introduced")
                else:
                    msg.critical(None, "Ошибка", "Не введены масляные канавки")
                self.progressBar.close()
                return 3
        elif self.engine.cil == "L6" or self.engine.cil == "V12":
            if self.data.excel['MN101'] == '-' or self.data.excel['MN102'] == '-' or self.data.excel['MN201'] == '-' or self.data.excel['MN202'] == '-' or self.data.excel['MN301'] == '-'\
            or self.data.excel['MN302'] == '-' or self.data.excel['MN401'] == '-' or self.data.excel['MN402'] == '-' or self.data.excel['MN501'] == '-' or self.data.excel['MN502'] == '-'\
            or self.data.excel['MN601'] == '-' or self.data.excel['MN602'] == '-' or self.data.excel['MN701'] == '-' or self.data.excel['MN702'] == '-':
                msg = QMessageBox()
                if dataf['lang'] != '':
                    msg.critical(None, "Error", "No oil grooves have been introduced")
                else:
                    msg.critical(None, "Ошибка", "Не введены масляные канавки")
                self.progressBar.close()
                return 3
        else:
            if self.data.excel['MN101'] == '-' or self.data.excel['MN102'] == '-' or self.data.excel['MN201'] == '-' or self.data.excel['MN202'] == '-' or self.data.excel['MN301'] == '-'\
            or self.data.excel['MN302'] == '-' or self.data.excel['MN401'] == '-' or self.data.excel['MN402'] == '-':
                msg = QMessageBox()
                if dataf['lang'] != '':
                    msg.critical(None, "Error", "No oil grooves have been introduced")
                else:
                    msg.critical(None, "Ошибка", "Не введены масляные канавки")
                self.progressBar.close()
                return 3
        self.expert.paths_to_folders.sort()
        if self.expert.input_mode1 == 1:
            match self.engine.cil:
                case "L3":
                    self.expert.cylinder = 3
                    self.expert.root_bearing = 4
                    self.expert.engine_type = "L3"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l3.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l3.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l3.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l3.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l3.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L4":
                    self.expert.cylinder = 4
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "L4"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l4.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    print(self.expert.paths_to_folders[0])
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l4.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l4.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l4.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l4.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L6":
                    self.expert.cylinder = 6
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "L6"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l6.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l6.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V6":
                    self.expert.cylinder = 6
                    self.expert.root_bearing = 4
                    self.expert.engine_type = "V6"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v6.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v6.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V8":
                    self.expert.cylinder = 8
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "V8"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v8.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v8.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v8.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v8.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v8.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V12":
                    self.expert.cylinder = 12
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "V12"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v12.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v12.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v12.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v12.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v12.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
        elif self.expert.input_mode1 == 2:
            match self.engine.cil:
                case "L3":
                    self.expert.cylinder = 3
                    self.expert.engine_type = "L3"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l3.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l3.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l3.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l3.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L4":
                    self.expert.cylinder = 4
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "L4"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l4.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l4.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l4.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l4.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L6":
                    self.expert.cylinder = 6
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "L6"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l6.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V6":
                    self.expert.cylinder = 6
                    self.expert.engine_type = "V6"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v6.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V8":
                    self.expert.cylinder = 8
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "V8"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v8.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v8.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v8.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v8.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V12":
                    self.expert.cylinder = 12
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "V12"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v12.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v12.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v12.code_4(self.expert.paths_to_folders[0], 1)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v12.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
        elif self.expert.input_mode2 == 1:
            match self.engine.cil:
                case "L3":
                    self.expert.cylinder = 3
                    self.expert.engine_type = "L3"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l3.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l3.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l3.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l3.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l3.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L4":
                    self.expert.cylinder = 4
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "L4"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l4.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l4.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l4.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l4.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l4.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L6":
                    self.expert.cylinder = 6
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "L6"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l6.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l6.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V6":
                    self.expert.cylinder = 6
                    self.expert.engine_type = "V6"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v6.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v6.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V8":
                    self.expert.cylinder = 8
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "V8"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v8.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v8.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v8.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v8.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v8.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V12":
                    self.expert.cylinder = 12
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "V12"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v12.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v12.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v12.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v12.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v12.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
        elif self.expert.input_mode2 == 2:
            match self.engine.cil:
                case "L3":
                    self.expert.cylinder = 3
                    self.expert.engine_type = "L3"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l3.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l3.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l3.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l3.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L4":
                    self.expert.cylinder = 4
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "L4"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l4.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l4.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l4.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l4.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L6":
                    self.expert.cylinder = 6
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "L6"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l6.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V6":
                    self.expert.cylinder = 6
                    self.expert.engine_type = "V6"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v6.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V8":
                    self.expert.cylinder = 8
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "V8"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v8.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v8.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v8.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v8.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V12":
                    self.expert.cylinder = 12
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "V12"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v12.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v12.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v12.code_4(self.expert.paths_to_folders[0], 2)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v12.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
        elif self.expert.input_mode3 == 1:
            match self.engine.cil:
                case "L3":
                    self.expert.cylinder = 3
                    self.expert.engine_type = "L3"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l3.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l3.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l3.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l3.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l3.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L4":
                    self.expert.cylinder = 4
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "L4"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l4.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l4.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l4.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l4.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l4.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L6":
                    self.expert.cylinder = 6
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "L6"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_l6.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l6.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V6":
                    self.expert.cylinder = 6
                    self.expert.engine_type = "V6"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v6.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v6.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V8":
                    self.expert.cylinder = 8
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "V8"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v8.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v8.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v8.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v8.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v8.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V12":
                    self.expert.cylinder = 12
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "V12"
                    self.progressBar.label.setText("Первый этап расчета")
                    try:
                        full_v12.code_1(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в первом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v12.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v12.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v12.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v12.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
        elif self.expert.input_mode3 == 2:
            match self.engine.cil:
                case "L3":
                    self.expert.cylinder = 3
                    self.expert.engine_type = "L3"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l3.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l3.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l3.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l3.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L4":
                    self.expert.cylinder = 4
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "L4"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l4.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l4.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l4.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l4.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "L6":
                    self.expert.cylinder = 6
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "L6"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_l6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_l6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_l6.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_l6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V6":
                    self.expert.cylinder = 6
                    self.expert.engine_type = "V6"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v6.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v6.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v6.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v6.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V8":
                    self.expert.cylinder = 8
                    self.expert.root_bearing = 5
                    self.expert.engine_type = "V8"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v8.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v8.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v8.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v8.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()
                case "V12":
                    self.expert.cylinder = 12
                    self.expert.root_bearing = 7
                    self.expert.engine_type = "V12"
                    self.progressBar.setValue(8, 18)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Второй этап расчета")
                    try:
                        full_v12.code_2(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка во втором этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(18, 35)
                    QApplication.processEvents()
                    self.progressBar.label.setText("Третий этап расчета")
                    QApplication.processEvents()
                    try:
                        full_v12.code_3(self.expert.paths_to_folders[0])
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в третьем этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Четвертый этап расчета")
                    self.progressBar.setValue(35, 65)
                    QApplication.processEvents()
                    try:
                        full_v12.code_4(self.expert.paths_to_folders[0], 3)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в четвертом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.label.setText("Пятый этап расчета")
                    try:
                        full_v12.code_5(self.expert.paths_to_folders[0], self.expert)
                    except Exception:
                        logging.info(traceback.format_exc() + "\n" + "-"*35)
                        msg = QMessageBox()
                        msg.critical(None, "Ошибка", "Ошибка в пятом этапе расчета")
                        self.progressBar.close()
                        return 3
                    self.progressBar.setValue(65, 75)
                    QApplication.processEvents()


        # else:
        #     print("FFF")
        #     self.path_to_folder = f"data/mode{self.page7.radio-1}"
        #     self.expert.mode = self.page7.radio
        #     self.expert.modes.append(self.page7.radio)
        #     word = '_res.xlsx'
        #     pattern = f"{self.path_to_folder}/*{word}*"
        #     self.path_to_file = glob.glob(pattern)[0]
        #     print(self.path_to_file)
        #     self.dict_from_excel = ReadExcel(self.path_to_file).getAllLists()
        #     match dict_engine[self.dict_from_excel['cil']]:
        #         case "L3":
        #             try:
        #                 full_l3.code_2(self.path_to_folder)
        #             except:
        #                 self.progressBar.close()
        #                 msg = QMessageBox()
        #                 msg.critical(None, "Ошибка", "Загрузите файл или проверьте его корректность")
        #                 return 3
        #             self.progressBar.setValue(18, 35)
        #             QApplication.processEvents()
        #             full_l3.code_3(self.path_to_folder)
        #             self.progressBar.setValue(35, 65)
        #             QApplication.processEvents()
        #             full_l3.code_4(self.path_to_folder)
        #             full_l3.code_5(self.path_to_folder, self.expert)
        #             self.progressBar.setValue(65, 75)
        #             QApplication.processEvents()
        #         case "L4":
        #             try:
        #                 full_l4.code_2(self.path_to_folder)
        #             except:
        #                 self.progressBar.close()
        #                 msg = QMessageBox()
        #                 msg.critical(None, "Ошибка", "Загрузите файл или проверьте его корректность")
        #                 return 3
        #             self.progressBar.setValue(18, 35)
        #             QApplication.processEvents()
        #             full_l4.code_3(self.path_to_folder)
        #             self.progressBar.setValue(35, 65)
        #             QApplication.processEvents()
        #             full_l4.code_4(self.path_to_folder)
        #             full_l4.code_5(self.path_to_folder, self.expert)
        #             self.progressBar.setValue(65, 75)
        #             QApplication.processEvents()
        #         case "L6":
        #             try:
        #                 full_l6.code_2(self.path_to_folder)
        #             except:
        #                 self.progressBar.close()
        #                 msg = QMessageBox()
        #                 msg.critical(None, "Ошибка", "Загрузите файл или проверьте его корректность")
        #                 return 3
        #             self.progressBar.setValue(18, 35)
        #             QApplication.processEvents()
        #             full_l6.code_3(self.path_to_folder)
        #             self.progressBar.setValue(35, 65)
        #             QApplication.processEvents()
        #             full_l6.code_4(self.path_to_folder)
        #             full_l6.code_5(self.path_to_folder, self.expert)
        #             self.progressBar.setValue(65, 75)
        #             QApplication.processEvents()
        #         case "V6":
        #             try:
        #                 full_v6.code_2(self.path_to_folder)
        #             except:
        #                 self.progressBar.close()
        #                 msg = QMessageBox()
        #                 msg.critical(None, "Ошибка", "Загрузите файл или проверьте его корректность")
        #                 return 3
        #             self.progressBar.setValue(18, 35)
        #             QApplication.processEvents()
        #             full_v6.code_3(self.path_to_folder)
        #             self.progressBar.setValue(35, 65)
        #             QApplication.processEvents()
        #             full_v6.code_4(self.path_to_folder)
        #             full_v6.code_5(self.path_to_folder, self.expert)
        #             self.progressBar.setValue(65, 75)
        #             QApplication.processEvents()
        #         case "V8":
        #             try:
        #                 full_v8.code_2(self.path_to_folder)
        #             except:
        #                 self.progressBar.close()
        #                 msg = QMessageBox()
        #                 msg.critical(None, "Ошибка", "Загрузите файл или проверьте его корректность")
        #                 return 3
        #             self.progressBar.setValue(18, 35)
        #             QApplication.processEvents()
        #             full_v8.code_3(self.path_to_folder)
        #             self.progressBar.setValue(35, 65)
        #             QApplication.processEvents()
        #             full_v8.code_4(self.path_to_folder)
        #             full_v8.code_5(self.path_to_folder, self.expert)
        #             self.progressBar.setValue(65, 75)
        #             QApplication.processEvents()
        #         case "V12":
        #             try:
        #                 QApplication.processEvents()
        #             except:
        #                 self.progressBar.close()
        #                 msg = QMessageBox()
        #                 msg.critical(None, "Ошибка", "Загрузите файл или проверьте его корректность")
        #                 return 3
        #             full_v12.code_2(self.path_to_folder)
        #             self.progressBar.setValue(18, 35)
        #             full_v12.code_3(self.path_to_folder)
        #             self.progressBar.setValue(35, 65)
        #             QApplication.processEvents()
        #             full_v12.code_4(self.path_to_folder)
        #             full_v12.code_5(self.path_to_folder, self.expert)
        #             self.progressBar.setValue(65, 75)
        #             QApplication.processEvents()
        self.expert.modes = sorted(self.expert.modes)
        # for x in self.expert.modes:
        #     x += 1

        self.countPage.enginesAdd(self.dict_from_excel)
        # self.countPage.setLabel(self.page7.radio)
        self.countPage.setLabel(self.expert.modes[0])
        # countPage = MainWindow('Без режима')
        # first_mode_countPage = MainWindow('Третий режим нагружения')
        # second_mode_countPage = MainWindow('Второй режим нагружения')
        # third_mode_countPage = MainWindow('Третий режим нагружения')

        first =  BigMainWidget(False, 'main')
        second = BigMainWidget(True, 'main')
        third = BigMainWidget(True, 'main')
        fourth = BigMainWidget(True, 'main')
        fifth = BigMainWidget(True, 'main')
        sixth = BigMainWidget(True, 'main')
        seventh = BigMainWidget(True, 'main')
        eighth = BigMainWidget(True, 'main')

        self.progressBar.setValue(75, 83)
        QApplication.processEvents()
        if dataf['lang'] != '':
            self.countPage.add_tab("Indicator pressure", first)
            self.countPage.add_tab("Forces", second)
            self.countPage.add_tab("Specific loads", third)
            self.countPage.add_tab("Trajectories", fourth)
            self.countPage.add_tab("Thickness of the oil film", fifth)
            self.countPage.add_tab("The angle of the direction of the oil film vector", sixth)
            self.countPage.add_tab("Oil pressure", seventh)
            self.countPage.add_tab("Friction losses", eighth)
        else:
            self.countPage.add_tab("Индикаторное давление", first)
            self.countPage.add_tab("Силы", second)
            self.countPage.add_tab("Удельные нагрузки", third)
            self.countPage.add_tab("Траектории", fourth)
            self.countPage.add_tab("Толщина масляной плёнки", fifth)
            self.countPage.add_tab("Угол направления вектора масляной пленки", sixth)
            self.countPage.add_tab("Давление масляной плёнки", seventh)
            self.countPage.add_tab("Потери на трение", eighth)


        self.path_to_res =  self.expert.paths_to_res[0]
        QApplication.processEvents()
        self.progressBar.setValue(83, 100)
        # self.countPage = MainWindow()
        self.countPage.show()
        self.progressBar.close()

        first.engineAdd()
        second.engineAdd()
        third.engineAdd()
        fourth.engineAdd()
        fifth.engineAdd()
        sixth.engineAdd()
        seventh.engineAdd()
        eighth.engineAdd()

        if self.countPage.isInit:
            self.AreTabsHere = False

        if not self.AreTabsHere:
            self.AreTabsHere = True

            PIND = MainWidget(self.path_to_res, 'cartesian')
            first.add_tab('CYLINDER PRESSURE', PIND)
            if not self.expert.count_graps:
                grap = Graphics(self.path_to_res, 0)
                self.expert.count_graps = True
            else:
                grap = Graphics(self.path_to_res, 1)
            PIND.graphic.PIND_graphic()
            PIND.graphic.remember_method(grap.PIND_graphic)
            # PIND.graphic.sc.fig.clf()

            PIND.table.new_tab(
                "CYLINDER PRESSURE",
                {
                    "PIND": PIND.graphic.excel.getPIND()
                },
            )
            PIND.remember_tabTable("PIND", "PIND", PIND.graphic.excel.getPIND())
            print("The tab of PIND was created")
        self.count_was = True 
        # print("fff" + self.path_to_res)
        # self.form = Form(self.path_to_res, self.dict_from_excel)
        # self.countPage


        # app.exec_()
        
    def show_page1(self):
        self.page1 = Page1()
        self.stackedWidget.addWidget(self.page1)
        self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
    def show_page2(self):
        self.page2 = Page2()
        self.stackedWidget.addWidget(self.page2)
        self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
    def show_page3(self):
        self.page3 = Page3()
        self.stackedWidget.addWidget(self.page3)
        self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
    def show_page4(self):
        self.page4 = Page4()
        self.stackedWidget.addWidget(self.page4)
        self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
    def show_page5(self):
        # if self.page7.radio == 1:
        #     word = '.xlsx'
        #     pattern = f"{'data'}/*{word}*"
        #     self.path_to_file = glob.glob(pattern)[0]
        #     print("page5 " + self.path_to_file)
        # elif self.page7.radio == 2:
        #     word = '_res.xlsx'
        #     pattern = f"{'data/mode1'}/*{word}*"
        #     self.path_to_file = glob.glob(pattern)[0]
        # elif self.page7.radio == 3:
        #     word = '_res.xlsx'
        #     pattern = f"{'data/mode2'}/*{word}*"
        #     self.path_to_file = glob.glob(pattern)[0]
        # elif self.page7.radio == 4:
        #     word = '_res.xlsx'
        #     pattern = f"{'data/mode3'}/*{word}*"
        #     self.path_to_file = glob.glob(pattern)[0]
        self.page5 = Page5()
        self.stackedWidget.addWidget(self.page5)
        self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
    def show_page6(self):
        self.page6 = Page6()
        self.stackedWidget.addWidget(self.page6)
        self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
    def show_page7(self):
        self.pushButton_21.setEnabled(True)
        self.page7 = Page7(self.path_to_file)
        self.stackedWidget.addWidget(self.page7)
        self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
    def handleActivated(self, index):
        self.expert.input_mode1 = 0
        self.expert.input_mode2 = 0
        self.expert.input_mode3 = 0
        self.expert.excel = {}
        self.expert.paths_to_folders = []
        self.expert.paths_to_res = []
        self.expert.modes = []
        try:
            with open('data/app.json', 'w') as file:
                json.dump({}, file)
        except:
            pass
        if self.err.show_page7:
            self.err.clear = 1
        self.pushButton_24.setEnabled(True)
        self.pushButton_23.setEnabled(True)
        # self.pushButton_21.setEnabled(True)
        self.engine.cil = self.comboBox.itemText(index)
        self.expert.engine_type = self.engine.cil
        self.action_2.setEnabled(True)
        self.action_3.setEnabled(True)
        self.path_to_folder = "data"
        if not os.path.isdir('data'):
            os.mkdir('data')
            dat = open('data/app.json', 'w')
            dat.write("{}")
            dat.close()

        else:
            shutil.rmtree('data')
            os.mkdir('data')
            dat = open('data/app.json', 'w')
            dat.write("{}")
            dat.close()
        match self.engine.cil:
            case "L3":
                self.expert.cylinder = 3
                self.expert.root_bearing = 4
                shutil.copy2('origin/data_l3.xlsx', self.path_to_folder)
                self.dict_from_excel = ReadExcel(self.path_to_folder + '/data_l3.xlsx').getAllLists()
                self.path_to_file = self.path_to_folder + '/data_l3.xlsx'
                self.data.excel = ReadExcel(self.path_to_folder + '/data_l3.xlsx').getAllLists()
            case "L4":
                self.expert.cylinder = 4
                self.expert.root_bearing = 5
                shutil.copy2('origin/data_l4.xlsx', self.path_to_folder)
                self.dict_from_excel = ReadExcel(self.path_to_folder + '/data_l4.xlsx').getAllLists()
                self.path_to_file = self.path_to_folder + '/data_l4.xlsx'
                self.data.excel = ReadExcel(self.path_to_folder + '/data_l4.xlsx').getAllLists()
            case "L6":
                self.expert.cylinder = 6
                self.expert.root_bearing = 7
                shutil.copy2('origin/data_l6.xlsx', self.path_to_folder)
                self.dict_from_excel = ReadExcel(self.path_to_folder + '/data_l6.xlsx').getAllLists()
                self.path_to_file = self.path_to_folder + '/data_l6.xlsx'
                self.data.excel = ReadExcel(self.path_to_folder + '/data_l6.xlsx').getAllLists()
            case "V6":
                self.expert.cylinder = 6
                self.expert.root_bearing = 4
                shutil.copy2('origin/data_v6.xlsx', self.path_to_folder)
                self.dict_from_excel = ReadExcel(self.path_to_folder + '/data_v6.xlsx').getAllLists()
                self.path_to_file = self.path_to_folder + '/data_v6.xlsx'
                self.data.excel = ReadExcel(self.path_to_folder + '/data_v6.xlsx').getAllLists()
            case "V8":
                self.expert.cylinder = 8
                self.expert.root_bearing = 5
                shutil.copy2('origin/data_v8.xlsx', self.path_to_folder)
                self.dict_from_excel = ReadExcel(self.path_to_folder + '/data_v8.xlsx').getAllLists()
                self.path_to_file = self.path_to_folder + '/data_v8.xlsx'
                self.data.excel = ReadExcel(self.path_to_folder + '/data_v8.xlsx').getAllLists()
            case "V12":
                self.expert.cylinder = 12
                self.expert.root_bearing = 7
                shutil.copy2('origin/data_v12.xlsx', self.path_to_folder)
                self.dict_from_excel = ReadExcel(self.path_to_folder + '/data_v12.xlsx').getAllLists()
                self.data.excel = ReadExcel(self.path_to_folder + '/data_v12.xlsx').getAllLists()
                self.path_to_file = self.path_to_folder + '/data_v12.xlsx'

        if self.stackedWidget.currentWidget() == self.page1:
            self.stackedWidget.removeWidget(self.page1)
            self.page1 = Page1()
            self.stackedWidget.addWidget(self.page1)
            self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
        elif self.stackedWidget.currentWidget() == self.page2:
            self.stackedWidget.removeWidget(self.page2)
            self.page2 = Page2()
            self.stackedWidget.addWidget(self.page2)
            self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
        elif self.stackedWidget.currentWidget() == self.page3:
            self.stackedWidget.removeWidget(self.page3)
            self.page3 = Page3()
            self.stackedWidget.addWidget(self.page3)
            self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
        elif self.stackedWidget.currentWidget() == self.page4:
            self.stackedWidget.removeWidget(self.page4)
            self.page4 = Page4()
            self.stackedWidget.addWidget(self.page4)
            self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
        elif self.stackedWidget.currentWidget() == self.page5:
            self.stackedWidget.removeWidget(self.page5)
            self.page5 = Page5()
            self.stackedWidget.addWidget(self.page5)
            self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
        elif self.stackedWidget.currentWidget() == self.page6:
            self.stackedWidget.removeWidget(self.page6)
            self.page6 = Page6()
            self.stackedWidget.addWidget(self.page6)
            self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
        elif self.stackedWidget.currentWidget() == self.page7:
            self.stackedWidget.removeWidget(self.page7)
            self.page7 = Page7(self.path_to_file)
            self.stackedWidget.addWidget(self.page7)
            self.stackedWidget.setCurrentIndex(self.stackedWidget.currentIndex()+1)
        self.toolBox.setEnabled(True)
        self.pushButton_4.setEnabled(True)
        self.pushButton_5.setEnabled(True)
        self.pushButton_7.setEnabled(True)
        self.pushButton_6.setEnabled(True)
        self.pushButton_2.setEnabled(True)
        self.pushButton_3.setEnabled(True)
        self.pushButton.setEnabled(True)
        # self.pushButton_24.clicked.connect(self.save)
        # self.pushButton_23.clicked.connect(self.save_as)
        # self.pushButton_6.setEnabled(True)

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    main_window = mainClass()
    main_window.show()
    main_window.setMinimumHeight(900)
    main_window.setMinimumWidth(1410)
    sys.exit(app.exec_())